/**
 * 
 */
package cn.bblocks.cacheTest.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.bblocks.cacheTest.model.Area;
import cn.bblocks.cacheTest.model.User;
import cn.bblocks.cacheTest.service.UserService;
import cn.bblocks.cacheTest.suport.dto.response.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @author jin
 *
 */
@RestController
@RequestMapping(value="/users")
public class UserController {
	@Autowired
	private UserService userService;

	@ApiOperation(value = "查看" )
    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
	public Response<User> getUser(@PathVariable Integer userId) {
		User user = userService.getUser(userId);

		
		return Response.getInstance( user);
	}
	

	
	@ApiOperation(value = "用户查询（测试Fenix动态sql）")
	@ApiImplicitParams({
        @ApiImplicitParam(name = "loginName", value = "loginName", required = false,paramType = "query"  ),
        @ApiImplicitParam(name = "name", value = "name", required = false,paramType = "query"  ),
        @ApiImplicitParam(name = "status", value = "status", required = false,dataType="Integer",paramType = "query"  ),
     })
	@RequestMapping(value = "/queryUsers", method = RequestMethod.GET)
	public Response<List<User>> queryUsers(String loginName,String name,Integer status) {
		List<User> users = userService.query(loginName, name, status);

		
		return Response.getInstance( users );
	}
	
	
}
